/**
 * Created by Yuko on 18/1/8.
 */
import config from 'config'
import httpFetch from 'share/httpFetch'

export default {
  //修改打印状态
  changePrintStatus(id, status) {
    return httpFetch.post(`${config.baseUrl}/api/invoice/batch/print/success?id=${id}&printSuccess=${status}`)
  },

  //打印
  printItem(id) {
    return httpFetch.get(`${config.baseUrl}/api/invoice/batch/print?id=${id}`)
  },

  //下载批次
  downloadReport(id){
    return httpFetch.get(`${config.baseUrl}/api/invoice/batch/report/download?id=${id}`, {}, {}, {responseType: 'arraybuffer'})
  },

  //删除
  delete(id){
    return httpFetch.delete(`${config.baseUrl}/api/invoice/batch/${id}`)
  },

  //获取失败数据
  getFailedBatch(){
    return httpFetch.get(`${config.baseUrl}/api/invoices/batch/failed/statistics`)
  },

  //获取批次
  getBatch(params){
    return httpFetch.post(`${config.baseUrl}/api/invoices/statistics`, params)
  },

  //下载failed数据
  downloadFail(){
    return httpFetch.get(`${config.baseUrl}/api/invoices/batch/failed/download`, {}, {}, {responseType: 'arraybuffer'})
  },

  //导出
  export(params){
    return httpFetch.post(`${config.baseUrl}/api/invoice/batch`, params)
  },

  //获取列表
  getList(params){
    let url = `${config.baseUrl}/api/invoice/batch/list?`;
    for(let paramsName in params) {
      url += params[paramsName] ? `&${paramsName}=${params[paramsName]}` : '';
    }
    return httpFetch.get(url);
  }
}
